package com.bleeth.hvbox;

import com.bleeth.fx.helper.ControlsHelper;
import com.bleeth.fx.layout.FormBuilder;
import com.bleeth.fx.layout.GirdCell;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Login_gitee_Main extends Application {
    @Override
    public void start(Stage stage) {
        show(stage);
    }

    public static void main(String[] args) {
        launch(args);
    }

    public static void show(Stage stage) {
        VBox loginForm = FormBuilder.form(500D, 500D)
                .addEmptyRow(50D)
                .addRow(GirdCell.createCell(100D, Pos.CENTER), GirdCell.createCell(4, Pos.CENTER_LEFT), GirdCell.createCell(4, Pos.CENTER_RIGHT),
                        GirdCell.createCell(100D, Pos.CENTER))
                .addCell(1, new Label("登录"))
                .addCell(2, new Label("没有帐号？ 点此注册"))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(100D, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER_LEFT), GirdCell.createCell(100D, Pos.CENTER))
                .coverCell(1, new TextField("admin"))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(100D, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER_LEFT), GirdCell.createCell(100D, Pos.CENTER))
                .coverCell(1, new TextField("password"))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(100D, Pos.CENTER), GirdCell.createCell(4, Pos.CENTER_LEFT), GirdCell.createCell(4, Pos.CENTER_RIGHT),
                        GirdCell.createCell(100D, Pos.CENTER))
                .addCell(1, new CheckBox("记住我"))
                .addCell(2, new Label("短信验证登录"))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(100D, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER_LEFT), GirdCell.createCell(100D, Pos.CENTER))
                .coverCell(1, new Button("登录"))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(100D, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER), GirdCell.createCell(100D, Pos.CENTER))
                .addCell(1, new Label("已有帐号，忘记密码？"))
                .endRow(false)
                .addEmptyRow(50D)
                .addRow(GirdCell.createCell(100D, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER), GirdCell.createCell(100D, Pos.CENTER))
                .coverCell(1, new Button("----------------------其它方式登录-----------------------"))
                .endRow(false)
                .build();
        loginForm.setStyle(ControlsHelper.randomBgColor());

        VBox leftForm = FormBuilder.form(500D, 500D)
                .addEmptyRow(50D)
                .build();
        leftForm.setStyle(ControlsHelper.randomBgColor());


        VBox root = FormBuilder.form(Pos.CENTER)
                .addRow(GirdCell.createCell(1, Pos.CENTER))
//                .addCell(0, leftForm)
                .addCell(0, loginForm)
                .endRow(false)
                .build();

        root.setStyle(ControlsHelper.randomBgColor());
        Scene scene = new Scene(root, 500D, 500D);
        root.prefHeightProperty().bind(scene.heightProperty());
        root.prefWidthProperty().bind(scene.widthProperty());
        stage.setScene(scene);
        stage.show();
    }


    public static VBox form() {
        VBox loginForm = FormBuilder.form(500D, 500D)
                .addEmptyRow(50D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(4, Pos.CENTER_LEFT), GirdCell.createCell(4, Pos.CENTER_RIGHT),
                        GirdCell.createCell(1, Pos.CENTER))
                .addCell(1, new Label("登录"))
                .addCell(2, new Label("没有帐号？ 点此注册"))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER_LEFT), GirdCell.createCell(1, Pos.CENTER))
                .coverCell(1, new TextField("admin"))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER_LEFT), GirdCell.createCell(1, Pos.CENTER))
                .coverCell(1, new TextField("password"))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(4, Pos.CENTER_LEFT), GirdCell.createCell(4, Pos.CENTER_RIGHT),
                        GirdCell.createCell(1, Pos.CENTER))
                .addCell(1, new CheckBox("记住我"))
                .addCell(2, new Label("短信验证登录"))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER_LEFT), GirdCell.createCell(1, Pos.CENTER))
                .coverCell(1, new Button("登录"))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER), GirdCell.createCell(1, Pos.CENTER))
                .addCell(1, new Label("已有帐号，忘记密码？"))
                .endRow(false)
                .addEmptyRow(50D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER), GirdCell.createCell(1, Pos.CENTER))
                .coverCell(1, new Button("----------------------其它方式登录-----------------------"))
                .endRow(false)
                .build();
        loginForm.setStyle(ControlsHelper.randomBgColor());

        VBox leftForm = FormBuilder.form(500D, 400D)
                .addEmptyRow(50D)
                .build();
        leftForm.setStyle(ControlsHelper.randomBgColor());


        VBox root = FormBuilder.form(Pos.CENTER)
                .addRow(GirdCell.createCell(1, Pos.CENTER))
                .addCell(0, leftForm)
                .addCell(0, loginForm)
                .endRow(false)
                .build();

        return root;
    }

}
